package ie.timalb.chess.main.core.rules.types;

import java.util.Iterator;

import ie.timalb.chess.main.core.Board;
import ie.timalb.chess.main.core.Turn;
import ie.timalb.chess.main.core.movement.Movement;
import ie.timalb.chess.main.core.movement.types.TypeOfMovement;
import ie.timalb.chess.main.core.rules.Rule;

public class ValidMovementRule implements Rule 
{

	@Override
	public boolean validateMovement(Turn turn, Movement mov, Board board) {
		boolean result = false;		
		
		Iterator<TypeOfMovement> typesOfMovement = mov.getPiece().getTypesOfMovement().iterator();
		while (typesOfMovement.hasNext())
		{
			TypeOfMovement typeOfMovement = typesOfMovement.next();
			if (typeOfMovement.isThisMovement(turn, mov, board))
			{
				result = true;
				break;
			}	
		}	
		
		return (result);
	}	
}
